home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 2
/
Amiga Tools 2.iso
/
tools
/
mg
/
src.lzh
/
amiga
/
dirio.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-23
|
2KB
|
81 lines
/*
* Name: MG 2x Directory I/O routines, by Stephen Walton Version of
* 5-May-88
*/
#include "no_dir.h"
#ifndef NO_DIR
#include "def.h"
#include "use_arp.h"
#ifdef USE_ARP
#include <arpfunctions.h>
#ifdef LATTICE
#include <libraries/arp_pragmas.h>
#endif
#endif
#ifdef ANSI
#include <string.h>
#endif
#undef NULL
#undef TRUE
#undef FALSE
#include <exec/types.h>
#include <intuition/intuition.h>
#include <libraries/dosextens.h>
#include <exec/memory.h>
#ifdef LATTICE
#include <proto/all.h>
#else
#include <functions.h>
#endif
extern char *MyDirName;
char *
getwd(path)
char *path;
{
if (!path)
return path;
strcpy(path, MyDirName);
return path;
}
chdir(path)
char *path;
{
BPTR AttemptLock;
struct FileInfoBlock *fib;
int retval;
extern char version[], WindowTitle[];
extern struct Window *EmW;
AttemptLock = Lock(path, ACCESS_READ);
if (!AttemptLock)
return -1;
fib = (struct FileInfoBlock *) AllocMem((long)
sizeof(struct FileInfoBlock),
MEMF_CLEAR);
Examine(AttemptLock, fib);
if (fib->fib_DirEntryType < 0) {
retval = -1;
UnLock(AttemptLock);
goto clean;
}
UnLock(CurrentDir(AttemptLock)); /* do the thing */
if (PathName(AttemptLock, MyDirName, MAXPATH) == 0)
MyDirName[0] = '\0';
retval = 0; /* Success! */
SetWindowTitles(EmW, WindowTitle, version);
clean:
FreeMem((void *) fib, (long) sizeof(struct FileInfoBlock));
return retval;
}
#else
#include "nullfile.h"
#endif